(async () => {
    // https://www.cnblogs.com/fslnet/p/10529202.html
    const redis = require('redis') // 引入 redis

    // 创建客户端
    const client =
        redis.createClient({
            url: 'redis://@192.168.0.13:6379' // 不写默认为 本地6379 的无账号密码 连接串
        })

    client.on('error', (err) => Promise.reject('Redis Client Error' + err))

    // 创建连接，是个 promise
    await client.connect();

    const msg = await client.get('msg');
    console.log(JSON.parse(msg))

    const list = await client.lRange("searchls", 0, -1);
    console.log(list)

    // const hash = await client.hGet("user:1", "name");
    // console.log(hash) // Alice

    await client.hSet("user:4", "name", "李四");
    await client.hSet("user:4", "age", "19");
    const hash = await client.hGetAll("user:1");
    console.log(hash)

    await client.quit();
})()
